<div class="js-response js-responses">

			<div class="l-curve-top l-curve-top-in">
				<div class="r-curve-top r-curve-top-in">
					<div class="top-bg top-bg-in"></div>
				</div>
			</div>
			<div class="shad-bg-lft shad-bg-lft-in">
				<div class="shad-bg-rgt shad-bg-rgt-in">
					<div class="shad-bg">
						<div class="center clearfix">
							<h3 class="idea-title1"><?php echo __l('Available for funding');?></h3>
							<div class="main-section clearfix">
							
								<?php
									$ol_class = "list idea-list";
									$li_class = "list feature-project-list idea-list";
								?>
								<ol class="clearfix <?php echo $ol_class; ?>">
									<?php
										if (!empty($projects)):
											$i = 0;
											foreach ($projects as $project):
												$class = null;
												if ($i++ % 2 == 0) {
													$class = 'alpha';							
												} else {
													$class = 'altrow alpha';
												}
									?>
									<li class="clearfix <?php echo $li_class; ?> <?php echo $class; ?>">
										<h3 class="idea-title"><?php echo $this->Html->link($this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words']),array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false, 'title' => $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words'])));?></h3>

                                        	<div class="clearfix userplace">
													<p class="grid_left"> <?php echo __l('by') . ' '; ?><?php echo $this->Html->link($this->Html->cText($project['User']['username']), array('controller' => 'users', 'action' => 'view', $project['User']['username']), array('escape' => false, 'title' => $this->Html->cText($project['User']['username'], false)));?></p>
													<p class="grid_left">
														<?php
															$location = array();
															$place = '';
															if (!empty($project['City'])):
																if (isset($project['City']['name']) && !empty($project['City']['name'])) {
																	$location[] = $project['City']['name'];
																}
															endif;
															if (!empty($project['Country']['name'])) :
																$location[] = $project['Country']['name'];
															endif;
															$place = implode(', ', $location);
															if ($place) :
																if(!empty($project['Country']['iso2'])):
														?>
															<span class="flags flag-<?php echo strtolower($project['Country']['iso2']); ?>" title ="<?php echo $project['Country']['name']; ?>"><?php echo $project['Country']['name']; ?></span>
														<?php
																endif;
																echo $this->Html->link($place, array('controller' => 'projects', 'action' => 'index', 'city' => $project['City']['slug']), array('escape' => false));
															endif;
														?>
													</p>
												</div>




                                        <?php $collected_percentage = ($project['Project']['collected_percentage']) ? $project['Project']['collected_percentage'] : 0;?>

										<div class="clearfix">
											<div class="grid_4 alpha omega">
												<?php echo $this->Html->link($this->Html->showImage('Project', $project['Attachment'], array('dimension' => 'normal_big_thumb', 'alt' => sprintf(__l('[Image: %s]'), $this->Html->cText($project['Project']['name'], false)), 'title' => $this->Html->cText($project['Project']['name'], false)),array('aspect_ratio' => 1)), array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false)); ?>
								
											</div>
												<div class="clearfix vote-count vote-count-small vote-count-idea">
													<?php if (Configure::read('Project.is_enable_idea')): ?>
														<div class="js-rating-display">
															<?php
																$average_rating = (!empty($project['Project']['project_rating_count'])) ? ($project['Project']['total_ratings']/$project['Project']['project_rating_count']) : 0;
																echo $this->element('_star-rating', array('project_id' => $project['Project']['id'], 'current_rating' => $average_rating,'total_rating' => $project['Project']['total_ratings'],'rating_count' => $project['Project']['project_rating_count'], 'canRate' => 0));
															?>
															<ul class="list count-list clearfix">
																<li class="supporters" title="<?php echo __l('Supporters'); ?>"><?php echo $this->Html->cInt($project['Project']['project_rating_count']); ?></li>
																<li class="average" title="<?php echo __l('Average votes'); ?>"><?php echo $this->Html->cFloat($average_rating); ?></li>
															</ul>
														</div>
													<?php endif; ?>
												</div>
										</div>
										<p class="description-content"><?php echo $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['short_description'], false), 200), $project['Project']['detected_suspicious_words']);?></p>
				                            <dl class="feature-list clearfix">
													<?php if(!Configure::read('Project.is_fb_project_comment_enabled')): ?>
														<dt class="comments" title="<?php echo __l('Comments'); ?>"><?php echo __l('Comments:') . ' '; ?></dt>
														<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_comment_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Comments'), array('escape' => false)); ?></dd>
													<?php endif; ?>
													<dt class="updates" title="<?php echo __l('Updates'); ?>"><?php echo __l('Updates:') . ' '; ?></dt>
													<dd>
														<?php
															if (!empty($project['Project']['feed_url']) && Configure::read('Project.is_enable_rss_feed')) {
																echo $this->Html->link($this->Html->cInt($project['Project']['project_feed_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Updates'), array('escape' => false));
															} else{
																echo $this->Html->link($this->Html->cInt($project['Project']['blog_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Updates'), array('escape' => false));
															}
														?>
													</dd>
													<dt class="views" title="<?php echo __l('Views'); ?>"><?php echo __l('Views:') . ' '; ?></dt>
													<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_view_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug']), array('escape' => false)); ?></dd>
												</dl>
												<div class="clearfix">
														<div class="progress-block clearfix">
															<p class="progress-bar" title = '<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>'>
																<span style="width:<?php echo ($collected_percentage > 100) ? '100%' : $collected_percentage.'%'; ?>;" title = "<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>"></span>
															</p>
														</div>
           										</div>
                                        <div class="clearfix">
											<dl class="deal-value grid_2">
												<?php if($project['Project']['project_status_id'] != ConstProjectStatus::Pending): ?>
													<dt><?php echo __l('funded') ?></dt>
													<dd><?php echo $this->Html->cInt($collected_percentage). __l('%');?></dd>
												<?php endif; ?>
											</dl>
												<dl class="deal-discount grid_2 alpha omega">
												<dt><?php echo __l('pledged') ?></dt>
												<dd><?php echo Configure::read('site.currency') . $this->Html->cCurrency($project['Project']['collected_amount']); ?></dd>
											</dl>
													<dl class="deal-save grid_2 alpha omega">
												<?php if (!empty($project['Project']['project_fund_goal_reached_date']) && $project['Project']['project_fund_goal_reached_date'] != '0000-00-00 00:00:00'): ?>
													<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_fund_goal_reached_date']); ?></dt>
													<dd><?php echo __l('funded'); ?></dd>
												<?php elseif($project['Project']['project_status_id'] == ConstProjectStatus::FundingExpired): ?>
													<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_funding_end_date']); ?></dt>
													<dd><?php echo __l('expired'); ?></dd>
												<?php elseif($project['Project']['project_status_id'] == ConstProjectStatus::ProjectCancelled): ?>
													<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_cancelled_date']); ?></dt>
													<dd><?php echo __l('Cancelled'); ?></dd>
												<?php else: ?>
													<dt><?php echo (round($project[0]['enddate']) >0) ? __l('days to go') : __l('hours to go'); ?></dt>
													<dd>
														<?php
															if ($project['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding || $project['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached || $project['Project']['project_status_id'] == ConstProjectStatus::GoalReached):
																if(round($project[0]['enddate']) >0):
																	echo $this->Html->cInt($project[0]['enddate']);
																else:
																	$end_time = intval(strtotime($project['Project']['project_funding_end_date'] . ' 23:59:59') - time());
														?>
														<div class="time-count">
															<div class="js-countdown">&nbsp;</div>
															<span class="js-time hide"><?php echo $this->Html->cInt($end_time,false);?></span>
														</div>
														<?php
																endif;
															endif;
														?>
													</dd>
												<?php endif; ?>
											</dl>
										</div>
									</li>
								<?php
										endforeach;
									else:
								?>
									<li class="main-section">
									 <div class="notice-block">
										<p class="notice"><?php echo __l('No Projects available'); ?></p>
                                     </div>
									</li>
								<?php
									endif;
								?>
							</ol>
							<div class="clearfix">
								<?php if (!empty($projects)) { ?>
									<?php if(!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'funding' && !empty($this->request->params['named']['view']) && $this->request->params['named']['view'] == 'home')
									{
									?>
									
									<?php
									}
									else
									{
									?>
									<div class="paging project-paging js-pagination"><?php echo $this->element('paging_links'); ?></div>
									
								<?php }} ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="l-curve-bot l-curve-bot-in">
			<div class="r-curve-bot r-curve-bot-in">
						<div class="bot-bg bot-bg-in"></div>
			</div>
		</div>
		<?php if(!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'funding' && !empty($this->request->params['named']['view']) && $this->request->params['named']['view'] == 'home')
									{
									?>
		<div><h3 class="idea-title"><?php echo $this->Html->link('View more projects',array('controller' => 'projects', 'action' => 'discover','admin' => false));?></h3></div>
		<?php
		}
		?>
</div>